package org.yumeko.mybatisplusdemo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.yumeko.mybatisplusdemo.mapper.UserMapper;
import org.yumeko.mybatisplusdemo.pojo.User;
import org.yumeko.mybatisplusdemo.service.UserService;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> queryUsers() {
        return this.userMapper.selectList(null);
    }

    @Override
    public User login(User user) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("name", user.getName()).eq("age", user.getAge());
        User tbuser = this.userMapper.selectOne(wrapper);
        return tbuser;
    }

    @Override
    public User queryUserByid(Integer userid) {
        return this.userMapper.selectById(userid);
    }
}
